
package com.shop.cloud.mall.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.mall.common.entity.SignRecord;
import com.shop.cloud.mall.admin.service.SignRecordService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 签到记录
 *
 * @author
 * @date 2021-01-13 15:29:30
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/signrecord")
@Tag(description = "signrecord", name = "签到记录管理")
public class SignRecordController {

    private final SignRecordService signRecordService;

    /**
     * 分页列表
     * @param page 分页对象
     * @param signRecord 签到记录
     * @return
     */
    @Operation(summary = "分页列表")
    @GetMapping("/page")
    @PreAuthorize("@ato.hasAuthority('mall:signrecord:index')")
    public R getPage(Page page, SignRecord signRecord) {
        return R.ok(signRecordService.page1(page, signRecord));
    }

    /**
     * 签到记录查询
     * @param id
     * @return R
     */
    @Operation(summary = "签到记录查询")
    @GetMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:signrecord:get')")
    public R getById(@PathVariable("id") String id) {
        return R.ok(signRecordService.getById(id));
    }

}
